{% block extra_block %}
<script>
    function reviewApplyAward(action, id) {
        var dialog = new bkDialog({
            type: 'dialog',
            title: '审核奖项',
            content: action === 1 ? '确认通过该奖项申报？' : '确认驳回该奖项申报？',
            confirmFn: function () {
                $.ajax({
                    url: '{{ SITE_URL }}review_apply_award/',
                    method: 'post',
                    data: {
                        "id": id,
                        "action": action
                    },
                    success: function (response) {
                        if (response['result']) {
                            new bkMessage({
                                message: response['message'],
                                theme: 'success'
                            })
                            applicationTable.ajax.reload(null, false)
                        } else {
                            // 失败处理
                            new bkMessage({
                                message: response['message'],
                                theme: 'error',
                                delay: 3000
                            });
                        }
                    }
                })
            }
        });
        dialog.show();
    }
</script>
{% endblock %}

<div class="modal fade" id="displayApplyAndAwardsModal" tabindex="1" role="dialog"
    aria-labelledby="displayApplyAndAwardsModalLabel" data-backdrop="static">
    <div class="modal-dialog" style="width: 1000px;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="displayApplyAndAwardsModalLabel">奖项查看</h4>
            </div>
            <div class="row">
                <div class="col-lg-6">
                    <div class="bk-form" style="padding: 10px">
                        <div class="bk-form-item">
                            <label class="bk-label" style="width:150px;">奖项名称：</label>
                            <div class="bk-form-content" style="margin-left:150px;">
                                <p id="display_edit_display_award_name" class="p_class"></p>
                            </div>
                        </div>
                        <div class="bk-form-item">
                            <label class="bk-label" style="width:150px;">评奖条件：</label>
                            <div class="bk-form-content" style="margin-left:150px;">
                                <p class="p_class" id="display_edit_display_requirement" style="word-break: break-word">
                                </p>
                            </div>
                        </div>
                        <div class="bk-form-item">
                            <label class="bk-label" style="width:150px;">奖项级别：</label>
                            <div class="bk-form-content" style="margin-left:150px;">
                                <p class="p_class" id="display_edit_display_award_level"></p>
                            </div>
                        </div>
                        <div class="bk-form-item">
                            <label class="bk-label" style="width:150px;">所属组织：</label>
                            <div class="bk-form-content" style="margin-left:150px;">
                                <p class="p_class" id="display_edit_display_belonging_org"></p>
                            </div>
                        </div>
                        <div class="bk-form-item">
                            <label class="bk-label" style="width:150px;">开始时间：</label>
                            <div class="bk-form-content" style="margin-left:150px;">
                                <p class="p_class" id="display_edit_display_start_datetime"
                                    name="display_start_datetime">
                                </p>
                            </div>
                        </div>
                        <div class="bk-form-item">
                            <label class="bk-label" style="width:150px;">结束时间：</label>
                            <div class="bk-form-content" style="margin-left:150px;">
                                <p class="p_class" id="display_edit_display_end_datetime"
                                    name="edit_display_end_datetime">
                                </p>
                            </div>
                        </div>
                        <div class="bk-form-item">
                            <label class="bk-label" style="width:150px;">是否需要附件：</label>
                            <div class="bk-form-content" style="margin-left:150px;">
                                <p class="p_class" id="display_edit_display_need_attachment"></p>
                            </div>
                        </div>
                        <div class="bk-form-item">
                            <label class="bk-label" style="width:150px;">奖项状态：</label>
                            <div class="bk-form-content" style="margin-left:150px;">
                                <p class="p_class" id="display_edit_display_status"></p>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-lg-6">
                    <form id="validate_form">
                        <input type="hidden" id="award_id" class="bk-form-input">
                        <input type="hidden" id="apply_id" class="bk-form-input">
                        <div class="bk-form" style="padding: 10px 28px 10px 0" id="validate_form">
                            <div class="bk-form-item">
                                <label class="bk-label" style="width:150px;">申报⼈/团队</label>
                                <div class="bk-form-content" style="margin-left:150px;">
                                    <p class="p_class" id="display_edit_applicant_info"></p>
                                </div>
                            </div>
                            <div class="bk-form-item">
                                <label class="bk-label" style="width:150px;">事迹介绍</label>
                                <div class="bk-form-content" style="margin-left:150px;">
                                    <p class="p_class" id="display_edit_introduction" style="word-break: break￾word">
                                    </p>
                                </div>
                            </div>
                            <div class="bk-form-item">
                                <label class="bk-label" style="width:150px;">附件</label>
                                <div class="bk-form-content" style="margin-left:150px;">
                                    <a href="" target="_blank" id="display_edit_attachment_url"><span
                                            class="bk-tag is-fillbk-primary">点击查看附件</span></a>
                                </div>
                            </div>
                            <div class="bk-form-item is-required">
                                <label class="bk-label" style="width:150px;">评奖</label>
                                <div class="bk-form-content" style="margin-left:150px;">
                                    <label class="bk-form-radio">
                                        <input type="radio" name="radio1" checked="checked" value=5>
                                        <i class="bk-radio-text">获 奖</i>
                                    </label>
                                    <label class="bk-form-radio">
                                        <input type="radio" name="radio1" value=4>
                                        <i class="bk-radio-text">未获奖</i>
                                    </label>
                                </div>
                            </div>
                            <div class="bk-form-item is-required">
                                <label class="bk-label" style="width:150px;">评语</label>
                                <div class="bk-form-content" style="margin-left:150px;">
                                    <textarea class="bk-form￾textarea" id="comment" name="comment"
                                        placeholder="请输⼊评语"></textarea>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
            <div class="modal-footer">
                <a class="bk-button bk-primary" id="submit" title="保 存" onclick="save()">
                    <span>保存</span>
                </a>
                <button type="button" class="bk-button bk-default" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
{% block extra_block %}
<script>
    function displayApplyAndAwardsModal(award_id, apply_id) {
        $.ajax({
            url: '{{ SITE_URL }}get_display_award_apply_info/' +
                award_id + '/' + apply_id,
            method: 'get',
            success: function (response) {
                if (response['result']) {
                    $("#display_edit_display_award_name").html(response.data.info.data.award_name);
                    $("#display_edit_display_requirement").html(response.data.info.data.requirement);
                    $("#display_edit_display_award_level").html(response.data.info.data.award_level);
                    $("#display_edit_display_belonging_org").html(response.data.info.data.belonging_org);
                    $("#display_edit_display_start_datetime").html(response.data.info.data.start_time);
                    $("#display_edit_display_end_datetime").html(response.data.info.data.end_time);
                    $("#display_edit_display_need_attachment").html(response.data.info.data.need_attachment);
                    $("#display_edit_display_status").html(response.data.info.data.status);
                    $("#award_id").val(response.data.info.data.award_id);
                    $("#apply_id").val(response.data.info.data.apply_id);
                    $("#display_edit_applicant_info").html(response.data.info.data.applicant_info);
                    $("#display_edit_introduction").html(response.data.info.data.introduction);
                    $("#display_edit_attachment_url").attr('href', "{{ SITE_URL }} " + response.data.info.data.attachment_url);
                    $("#display_comment").html(response.data.info.data.comment);
                    $("#display_state").html(response.data.info.data.state);
                } else {
                    // 失败处理
                    new bkMessage({
                        message: response['message'],
                        theme: 'error',
                        delay: 3000
                    });
                }
            }
        })
    }
    $('#validate_form').validate({
        ignore: '.ignore',
        errorElement: 'div', //错误信息的容器
        errorClass: 'is-danger',
        errorPlacement: function (error, element) {
            error.addClass('bk-form-tip').insertAfter(element)
        },
        success: function (label) { //验证通过的提示图标
            label.html('<div class="bk-badge bk-success"><i class= "bk-icon icon-check-1" ></i ></div > ');
        },
        validClass: "bk-valid",
        //验证规则
        rules: {
            comment: {
                required: true,
            }
        },
        //错误提示信息
        messages: {
            comment: "<p class='bk-tip-text'>评语为必填项！</p> ",
        }
    });
    function save() {
        if ($('#validate_form').valid()) {
            var award_id = $('#award_id').val()
            var apply_id = $('#apply_id').val()
            $.ajax({
                url: '{{ SITE_URL }}save_awards_apply_info/',
                method: 'post',
                data: {
                    'award_id': award_id,
                    'apply_id': apply_id,
                    'state': $("input[name='radio1']:checked").val(),
                    'comment': $('#comment').val(),
                    'csrfmiddlewaretoken': "{{ csrf_token }}"
                },
                success: function (response) {
                    if (response['result']) {
                        new bkMessage({
                            message: response['message'],
                            theme: 'success'
                        })

                        $('#displayApplyAndAwardsModal').modal('hide')
                        applicationTable.ajax.reload(null, false)
                    } else {
                        // 失败处理
                        new bkMessage({
                            message: response['message'],
                            theme: 'error',
                            delay: 3000
                        });
                    }
                }
            })
        }
    }
    $('#displayApplyAndAwardsModal').on('hide.bs.modal', function () {
        document.getElementById("validate_form").reset();
        $("#validate_form").validate().resetForm();
        $('#comment').val("");
    });
</script>
{% endblock %}